package org.restorator.service;

import org.restorator.exception.ServiceException;

import java.io.Serializable;
import java.util.List;

/**
 * @author Snisar Bogdan.
 */
public interface CrudService <E, ID extends Serializable> {
    /**
     * Get entity by id
     */
    E get(ID primaryKey) throws ServiceException;

    /**
     * Update entity.
     *
     * @param entity
     */
    void update(E entity)throws ServiceException;

    /**
     * Save new entity
     * @param entity new obj
     * @return entity id
     */
    ID save(E entity, Object...arg)throws ServiceException;

    /**
     * Delete this entity.
     * @param entity
     */
    void delete(E entity)throws ServiceException;

    /**
     * Return all entities.
     *
     */
    List<E> getAll()throws ServiceException;
}
